package com.saltlux.storm.study.bbs.impl.h2;

import java.sql.Connection;
import java.sql.DriverManager;

public class ConnectionManager {
	private static Connection SINGLETON = null;
	
	public synchronized static Connection getConnection() {
		if(SINGLETON == null) {
			SINGLETON = newConnection();
		}
		
		return SINGLETON;
	}

	private static Connection newConnection() {
		Connection conn = null;
		try {
			Class.forName(org.h2.Driver.class.getName());
			
			conn = DriverManager.getConnection("jdbc:h2:mem:");
		} catch(Exception e) {
			e.printStackTrace();
		}
		return conn;
	}
}
